/*
	Copyright 2009 Benjamin Vedder	vedder87@gmail.com
	
	This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
    */

package com.google.code.retrobox.editor.commons.dialog;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

import com.google.code.retrobox.editor.MainWindow;


public class AboutDialog extends JDialog implements ActionListener {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private String gpl = "GPL v3";
	
	// Componente
	private JButton closeButton = new JButton("Close");
	
	private JTabbedPane tp = new JTabbedPane();
	
	// Panels
	private JPanel mainPanel = new JPanel(new BorderLayout());
	
	// Labels
	private JLabel upperLabel = new JLabel();
	private JLabel lowerLabel = new JLabel();
	
	// Text areas
	private JTextArea licenseArea = new JTextArea();
	private JTextArea libArea = new JTextArea();
	
	public AboutDialog(JFrame parent) {
		super(parent, false);
		setLayout(new BorderLayout());
		
		upperLabel.setText("<html><font color=blue><font size=5>RetroBox Game Assets Manager v</font size=5></font color=blue> " + 
				"<font size=5><font color=red>" + MainWindow.versionNumber + "</font color=red></font size=5><BR><BR>" +
						"This program aims to be a tool to edit tiles and maps compatible with the AVGA platform. " +
						"<br><br>" +
						"Based upon code of AVGA editor by Benjamin Vedder.<br>" +
						"Current codebase by Luc De pauw.<br>" +
						
						"</html>");
		
		lowerLabel.setText("<html>Licensed under GNU GPL V3. " +
				"Mail: retrobox@wodan.be</html>");
		
		mainPanel.add(upperLabel, BorderLayout.NORTH);
		mainPanel.add(lowerLabel, BorderLayout.SOUTH);
		
		
		libArea.setText("Libraries used: \n\n" +
				"No additional libraries are used by this program, just java and pure swing. Enjoy :)");
		
		licenseArea.setText(gpl);
		
		libArea.setEditable(false);
		licenseArea.setEditable(false);
		
		closeButton.addActionListener(this);
		
		JScrollPane libScroll = new JScrollPane(libArea);
		JScrollPane licenseScroll = new JScrollPane(licenseArea);
		
		tp.addTab("About", null,  mainPanel, "About");
		tp.addTab("Libraries", null,  libScroll, "Libreries used by this program");
		tp.addTab("License", null,  licenseScroll, "License agreement");
		
		setTitle("About this tool");
		setSize(new Dimension(550, 300));
		setLocationRelativeTo(null);
		setDefaultCloseOperation(DISPOSE_ON_CLOSE);
		setVisible(true);
		add(tp, BorderLayout.CENTER);
		add(closeButton, BorderLayout.SOUTH);
	}

	public void actionPerformed(ActionEvent arg0) {
		if (arg0.getSource() == closeButton) {
			dispose();
		}
	}
}